package CreationalPatterns.Prototype;

import java.util.HashMap;

public class ShapeCache {

  public static HashMap<Integer,Shape> hashMap =  new HashMap<>();

  public static Shape getShape(int id){
    Shape shape = hashMap.get(id);
    return (Shape) shape.clone();
  }

  public static void loadCache(){
    Circle circle = new Circle();
    circle.setId(1);
    hashMap.put(circle.getId(),circle);

    Rectangle rectangle = new Rectangle();
    rectangle.setId(2);
    hashMap.put(rectangle.getId(),rectangle);
  }
}
